$(function() {

    var autocompleteWidth;
    var buttonWidth;
    var finalWidth;

    $('.ui-autocomplete').each(function() {
        $(this).css({'display': 'inline-block', 'width': '100%'});
        autocompleteWidth = $(this).outerWidth();
        buttonWidth = $(this).children('button').outerWidth();
        finalWidth = autocompleteWidth - buttonWidth;
        $(this).children('input').css({'width': finalWidth - 1});
    });
    
    $('.hasDatepicker').each(function() {
        $(this).css({'display': 'inline-block', 'width': '100%'});
        autocompleteWidth = $(this).outerWidth();
        buttonWidth = $(this).next('button').outerWidth();
        finalWidth = autocompleteWidth - buttonWidth;
        $(this).css({'width': finalWidth - 1});
    });
    
});
